auto();
device.keepScreenOn();
var num = 0
var b = rawInput("关注抖音的关键字", "Tempted44");
var c = rawInput("关注多少个，不建议超过60个", "80");
launchApp("抖音短视频");
text("朋友").waitFor()
toastLog('抖音界面,延迟3秒')
sleep(3000)
setScreenMetrics(1080, 1920);
sleep(random(2000, 4000));
click("我");//988, 1766
sleep(random(2000, 4000));
click("朋友");//988, 1766
sleep(random(2000, 6000));
click(264, 236);//搜索框
sleep(random(2000, 4000));
setText(b);
sleep(random(2000, 4000));
click("搜索");
sleep(random(2000, 12000));
click(b);
sleep(random(4000, 12000));
var ra = id("f42").findOne(5000)             //上面的关注或者是回关按钮
if (ra != null) {
    ra.click();
    sleep(1 * 60 * 1000);                                       //新号设置时间一小时以上
}

var a = text("粉丝").findOne(5000)
if (a != null) {
    let xy = a.bounds()
    click(xy.centerX(), xy.centerY())
} else {
    alert("找不到节点")
}
sleep(random(4000, 12000));

while (num != c) {
    var target = text("关注").findOnce() || text("回关").findOnce();
    if (target == null) {
        swipe(device.width / 622, 1768, device.width / 542, 222, 860);
        sleep(2000)
    }else{
        target.click();
        num++
        sleep(random(3000, 8000));
    }
    sleep(2000)
}